
#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = l; i <= r; ++i)
using namespace std;
typedef long long ll;
const int N = 2e3 + 7;
const int mod = 1e9 + 7;
int n;        // 点数
int g[N][N];  // 邻接矩阵存图
void floyd() {
    for (int k = 1; k <= n; k++) {
        for (int x = 1; x <= n; x++) {
            for (int y = 1; y <= n; y++) {
                g[x][y] = min(g[x][y], g[x][k] + g[k][y]);
            }
        }
    }
}